package com.hbqyml.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hbqyml.common.annotation.Log;
import com.hbqyml.common.core.controller.BaseController;
import com.hbqyml.common.core.domain.AjaxResult;
import com.hbqyml.common.enums.BusinessType;
import com.hbqyml.system.domain.HbClassify;
import com.hbqyml.system.service.IHbClassifyService;
import com.hbqyml.common.utils.poi.ExcelUtil;
import com.hbqyml.common.core.page.TableDataInfo;

/**
 * 类型Controller
 * 
 * @author houyutong
 * @date 2022-03-25
 */
@RestController
@RequestMapping("/system/classify")
public class HbClassifyController extends BaseController
{
    @Autowired
    private IHbClassifyService hbClassifyService;

    /**
     * 查询类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:classify:list')")
    @GetMapping("/list")
    public TableDataInfo list(HbClassify hbClassify)
    {
        startPage();
        List<HbClassify> list = hbClassifyService.selectHbClassifyList(hbClassify);
        return getDataTable(list);
    }

    /**
     * 导出类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:classify:export')")
    @Log(title = "类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HbClassify hbClassify)
    {
        List<HbClassify> list = hbClassifyService.selectHbClassifyList(hbClassify);
        ExcelUtil<HbClassify> util = new ExcelUtil<HbClassify>(HbClassify.class);
        util.exportExcel(response, list, "类型数据");
    }

    /**
     * 获取类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:classify:query')")
    @GetMapping(value = "/{classifyId}")
    public AjaxResult getInfo(@PathVariable("classifyId") Integer classifyId)
    {
        return AjaxResult.success(hbClassifyService.selectHbClassifyByClassifyId(classifyId));
    }

    /**
     * 新增类型
     */
    @PreAuthorize("@ss.hasPermi('system:classify:add')")
    @Log(title = "类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HbClassify hbClassify)
    {
        return toAjax(hbClassifyService.insertHbClassify(hbClassify));
    }

    /**
     * 修改类型
     */
    @PreAuthorize("@ss.hasPermi('system:classify:edit')")
    @Log(title = "类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HbClassify hbClassify)
    {
        return toAjax(hbClassifyService.updateHbClassify(hbClassify));
    }

    /**
     * 删除类型
     */
    @PreAuthorize("@ss.hasPermi('system:classify:remove')")
    @Log(title = "类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classifyIds}")
    public AjaxResult remove(@PathVariable Integer[] classifyIds)
    {
        return toAjax(hbClassifyService.deleteHbClassifyByClassifyIds(classifyIds));
    }
}
